package com.service.business.product.controller;

import com.service.core.rest.BaseController;
import com.service.core.rest.request.PageRequest;
import com.service.core.rest.response.OneResponse;
import com.service.core.rest.response.PageResponse;
import com.service.dao.enums.ProductEnums;
import com.service.business.framework.log.RequestLog;
import com.service.business.product.controller.rep.ProductOtherDetailRep;
import com.service.business.product.controller.rep.ProductOtherPageRep;
import com.service.business.product.service.ProductOtherService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <dl>
 * <dt>back-end</dt>
 * <dd>Description:</dd>
 * <dd>Copyright: Copyright (C) 2015</dd>
 * <dd>Company: </dd>
 * <dd>CreateDate: 2019年11月12日</dd>
 * </dl>
 *
 * @author
 */
@Slf4j
@RestController
@RequestMapping("product-other")
public class ProductOtherController extends BaseController {

    @Autowired
    private ProductOtherService productOtherService;

    @RequestLog("礼包分页接口")
    @PostMapping("page/{categoryId}/{productType}")
    public PageResponse<ProductOtherPageRep> pageProduct(@PathVariable("categoryId") Integer categoryId, @PathVariable("productType") ProductEnums.Type productType, PageRequest pageRequest) {
        return successQueryPageResponse(productOtherService.pageProduct(categoryId, productType, pageRequest));
    }

    @RequestLog("礼包详情")
    @GetMapping("detail/{productId}")
    public OneResponse<ProductOtherDetailRep> productDetail(@PathVariable("productId") Integer productId) {
        return successQueryOneResponse(productOtherService.detail(productId));
    }

}
